//
//  BBTestRequest.m
//  BabyThermometer
//
//  Created by CaiLei on 10/14/14.
//  Copyright (c) 2014 baohu. All rights reserved.
//

#import "BBTestRequest.h"
@implementation BBTestRequestItem
@end

@implementation BBTestRequest {
    void(^_completeBlock)(BBTestRequestItem *retItem, NSError *error);
}

- (id)init {
    self = [super init];
    if (self) {
        self.urlHead = @"http://baohuquan.sinaapp.com/servlet/Test";
    }
    
    return self;
}

- (void)startRequestWithBlock:(void(^)(BBTestRequestItem *retItem, NSError *error))aCompleteBlock {
    _completeBlock = aCompleteBlock;
    [self startRequest];
}

- (void)dealWithResponseJson:(NSString *)aJson andError:(NSError *)aError {
    if (aError) {
        _completeBlock(nil, aError);
    }
    
    BBTestRequestItem *item = [[BBTestRequestItem alloc] initWithString:aJson error:&aError];
    if (aError) {
        _completeBlock(nil, aError);
    } else {
        _completeBlock(item, nil);
    }    
}

@end
